<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>函数求阶乘</title>
</head>
<body>
<script>
    function getJC(n) {
        if (n === 0 || n === 1) {
            return 1;
        } else {
            var result = 1;
            for (var i = 2; i <= n; i++) {
                result *= i;
            }
            return result;
        }
    }

    function getSum(a) {
        var sum = 0;
        for (var i = 1; i <= a; i++) {
            sum += getJC(i);
        }
        return sum;
    }

    var factorialOf3 = getJC(3);
    var sumOfFactorials = getSum(3);

    alert("3 的阶乘是 " + factorialOf3 + "\n" +
        "3 的阶乘累加和是 " + sumOfFactorials);
</script>
</script>
</body>
</html>